import { exportExcel, request , uploadFile } from './request';
export {
  getGameList,//获取赛事列表
  getGameDetail,//赛事详情
  getGameDetailRule,//赛事详情-赛事介绍
  // getPosDetail,
  uploadPic,
  createGame,
  login,
  expComList,
  addClub,
  joinGame,
  saveDraw,
  getDraw,
  exportDraw,
  exportDraw2,
  importPlayer,
  joiner_list,
  club_apply_detail,
  addClub_record_apply_id,//
  userUpdate,
  joinGameRevoke,
  club_login,
  activity_list,
  create_activity,
  activity_detail,
  join_activity,
  subscribe,
  region_list,
  getFollowClub,
  downLoadComTem,
  writeScore,
  getScore,
  getClubList,
  revoke_join_activity,
  getSlide,
  getGrid,
  get_club_agreement,
}
const AccessKeyId:string = "MzEzMjE3MTI5MDU4NDM=";//todo 放到后端
const AccessKeySecret:string = "MTdkNDE1MzhjNWU0NzVlZTNhMzkyMTUxZDYxNjZjOWY=";//todo 放到后端
//获取赛事列表
const getGameList = (data:{
  AccessKeyId?:string,
  AccessKeySecret?:string,
  type?:number,
  visit_gfid?:number|string,
  club_id?:number | string,
}={}) => {
  return request({
    url: 'getGameList',
    method: 'GET',
    data: {
      AccessKeyId: data.AccessKeyId||AccessKeyId,
      AccessKeySecret: data.AccessKeySecret||AccessKeySecret,
      type:data.type||1,
      visit_gfid:data.visit_gfid||'',
      club_id:data.club_id||'',
    },
  })
}
//获取详情
const getGameDetail = (data:{game_id:string|number,AccessKeyId?:string,
  AccessKeySecret?:string,GF_ID:string|number}) => {
  return request({
    url: 'getGameDetail',
    method: 'GET',
    data: {
      AccessKeyId: data.AccessKeyId||AccessKeyId,
      AccessKeySecret: data.AccessKeySecret||AccessKeySecret,
      game_id:data.game_id,
      visit_gfid:data.GF_ID,
    },
  })
}
const getGameDetailRule = (id:string) => {
  return request({
    url: 'getGameDetailRule',
    method: 'GET',
    data: {
      id:id
    },
  })
}
// const getPosDetail = (game_id:string|number) => {
//   return request({
//     url: 'getGameDetail',
//     method: 'GET',
//     data: {
//       AccessKeyId: AccessKeyId,
//       AccessKeySecret: AccessKeySecret,
//       game_id:game_id,
//     },
//   })
// }
//上传图片接口
const uploadPic = (filePath:string,fileName:string='file') => {
  return uploadFile({
    url: 'uploadPic',
    filePath:filePath,
    name:fileName,
    data: {
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
    },
  })
}
//发布赛事
const createGame = (data:{
  game_title: string, //比赛名称
  game_time: string, //比赛时间
  game_address: string, //比赛地址
  Signup_date_end: string, //报名截止时间
  local_and_phone: string, //联系电话
  game_player_team: string, //665-单人，666团体
  number_of_member: string, //限报人数
  minimum_team: number, //每队人数,单人比赛默认为1
  game_money: string, //报名费用
  isSignOnline: string, //收费方式 641-线下收费，642-在线缴费
  game_online: string, //648-隐藏比赛，649-显示比赛
  intro_content_temp: string, //赛事介绍内容
  game_small_pic: string, //赛事缩略图 2024/04/11/1712803327254_0.png
  game_big_pic: string, //赛事详情滚动图，多图用","隔开
  AccessKeyId:string,
  AccessKeySecret:string,
}) => {
  return request({
    url: 'createGame',
    method: 'GET',
    data: data,
  })
}
//用户登录/注册
const login = (data:{code:string,phone_code:string}) => {
  return request({
    url: 'login',
    method: 'GET',
    data: {
      code:data.code,
      phone_code:data.phone_code,
    },
  })
}
//导出赛事报名选手列表
const expComList= (list:any,detail:any,fileName:string) => {
  return exportExcel({
    fileName:fileName,
    url: 'expComList',
    method: 'GET',
    data: {
      list:list,
      detail:detail,
      fileName:fileName,
    },
  })
}
const addClub = (data:{
  //单位机构基本信息
  company : string, //申请单位名称
  company_type_id : string, //申请单位性质'1407-行政机关','1408-事业单位','1409-社团','1410-企业单位','1411-个体经营'
  
  club_name : string, //服务机构名称，即前端显示的名称
  club_logo_pic : string, //服务机构logo
  club_area_code : string, //所在地区
  club_address : string, //详细地址
  login_password:string,//密码
  apply_club_gfid:string,
  //单位机构合法性信息
  valid_until_start: string, //营业期限开始时间
  valid_until: string, //营业期限截止时间，不填默认为长期
  certificates: string, //营业执照

  //???
  //apply_club_gfid: string, //关联GF账号id

  //联系人信息
  apply_name: string, //联系人
  contact_phone: string, //联系电话
  email: string, //电子邮箱

  //法人信息
  apply_club_gfnick: string, //法人姓名
  apply_club_phone: string, //法人联系电话
  apply_club_id_card: string, //法人身份证号
  legal_person_id_card_face: string, //法人身份证照片人像面
  legal_person_id_card_back: string, //法人身份证照片国徽面

  //银行及税务信息
  bank_name: string, //开户银行
  bank_branch_name: string, //支行名称
  bank_account: string, //银行帐号
  taxpayer_type: string, //是否为一般纳税人，648-否，649-是
  taxpayer_pic: string, //一般纳税人证明（照片），taxpayer_type=649时需要传入
}) => {
  //未完成
  let data2:any =data;
  data2['AccessKeyId']=AccessKeyId;
  data2['AccessKeySecret']=AccessKeySecret;
  return request({
    url: 'addClub',
    method: 'GET',
    data: data,
  })}
//joinGame
const joinGame = (data:{GF_ID:string|number,game_id:string|number,game_data_id:string|number,team_logo:string,team_name:string,tour_leader_name?:string,tour_leader_phone?:string}) => {
  return request({
    url: 'joinGame',
    method: 'GET',
    data: {
      visit_gfid:data.GF_ID,
      game_id :data.game_id ,
      game_data_id :data.game_data_id ,
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
      team_logo: data.team_logo,
      team_name:data.team_name,
      tour_leader_name:data.tour_leader_name,
      tour_leader_phone:data.tour_leader_phone,
    },
  })
}
const saveDraw = (data:{GF_ID:string|number,game_id:string|number,game_data_id:string|number,data:string,type:number}) => {
  return request({
    url: 'saveDraw',
    method: 'GET',
    data: {
      GF_ID:data.GF_ID,
      game_id :data.game_id ,
      game_data_id :data.game_data_id ,
      data:data.data,
      type:data.type,
    },
  })
}
const getDraw = (data:{game_id:string|number,game_data_id:string|number}) => {
  return request({
    url: 'getDraw',
    method: 'GET',
    data: {
      game_id :data.game_id ,
      game_data_id :data.game_data_id ,
    },
  })
}
const userUpdate = (data:{openid:string,name:string,head_pic:string,GF_ID:number|string,GF_account:string,sex:string}) => {
  return request({
    url: 'userUpdate',
    method: 'GET',
    data: {
      openid:data.openid,
      gf_name :data.name ,
      head_pic :data.head_pic ,
      GF_ID:data.GF_ID,
      sex:data.sex,
      GF_Account:data.GF_account,
    },
  })
}
//exportDraw
const exportDraw= (list:any,detail:any,fileName:string) => {
  return exportExcel({
    fileName:fileName,
    url: 'exportDraw',
    method: 'GET',
    data: {
      list:list,
      detail:detail,
      fileName:fileName,
    },
  })
}
const exportDraw2= (list:any,detail:any,fileName:string) => {
  return exportExcel({
    fileName:fileName,
    url: 'exportDraw2',
    method: 'GET',
    data: {
      list:list,
      detail:detail,
      fileName:fileName,
    },
  })
}
const importPlayer =(data:{filePath:string,game_id:string | number,game_data_id:string | number,GF_ID:string | number}) => {
  return uploadFile({
    url: 'importPlayer',
    filePath: data.filePath,
    name:"file",
    data: {
      game_id:data.game_id,
      game_data_id:data.game_data_id,
      GF_ID:data.GF_ID,
    },
  })
}
const joiner_list = (data:{game_id:string|number,game_data_id:string|number}) => {
  return request({
    url: 'joiner_list',
    method: 'GET',
    data: {
      game_id :data.game_id ,
      game_data_id :data.game_data_id ,
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
    },
  })
}
// club_apply_detail
const club_apply_detail = (data:{visit_gfid:string|number,apply_id:string|number}) => {
  return request({
    url: 'club_apply_detail',
    method: 'GET',
    data: {
      visit_gfid :data.visit_gfid ,
      apply_id:data.apply_id ,
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
    },
  })
}
const addClub_record_apply_id = (data:{openid:string,apply_id:string|number}) => {
  return request({
    url: 'addClub_record_apply_id',
    method: 'GET',
    data: {
      openid:data.openid,
      apply_id:data.apply_id,
    },
  })
}
//退出报名
const joinGameRevoke = (data:{GF_ID:string | number,game_data_id:string|number}) => {
  return request({
    url: 'joinGameRevoke',
    method: 'GET',
    data: {
      visit_gfid :data.GF_ID,
      game_data_id:data.game_data_id,
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
    },
  })
}
const club_login = (data:{club_code:string,password:string}) => {
  return request({
    url: 'club_login',
    method: 'GET',
    data: {
      club_code:data.club_code,
      password:data.password,
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
    },
  })
}
const activity_list = (data:{type?:number,GF_ID?:string | number,AccessKeyId?:string,AccessKeySecret?:string,club_id?:string|number}) => {
  return request({
    url: 'activity_list',
    method: 'GET',
    data: {
      AccessKeyId: data.AccessKeyId||AccessKeyId,
      AccessKeySecret: data.AccessKeySecret||AccessKeySecret,
      type:data.type||1,
      visit_gfid:data.GF_ID||0,
      club_id:data.club_id||'',
    },
  })
}
const create_activity = (data:{
  activity_title : string,//活动标题,
  activity_address :string, //活动地点,
  local_and_phone :string, //联系电话,
  apply_number :string, //可报名人数,
  activity_money :string, //活动费用（元）,
  isSignOnline : string,//收费方式 641-线下报名，642-在线报名
  show_signlist:string,//是否显示报名名单，1-显示，0-不显示
  //选填项:
  activity_small_pic : string,//缩略图,
  activity_big_pic :string, //滚动图,
  activity_online :string, //显示前端,
  dispay_star_time :string, //前端显示时间,
  dispay_end_time :string, //前端显示时间,
  sign_up_date :string, //报名时间,
  sign_up_date_end :string, //报名截止时间,
  effective_time :string, //缴费截止日期,
  activity_time :string, //活动开始日期,
  activity_time_end :string, //活动截止日期,
  local_men :string, //联系人,
  intro_content_temp :string, //介绍
  AccessKeyId:string,
  AccessKeySecret:string,
},) => {
  return request({
    url: 'create_activity',
    method: 'GET',
    data: data,
  })
}
const activity_detail = (data:{GF_ID:string,activity_id:string}) => {
  return request({
    url: 'activity_detail',
    method: 'GET',
    data: {
      visit_gfid:data.GF_ID,
      id:data.activity_id,
      AccessKeyId:'MzEzMjE3MTI5MDU4NDM=',
      AccessKeySecret:'TdkNDE1MzhjNWU0NzVlZTNhMzkyMTUxZDYxNjZjOWY=',
    },
  })
}
//join_activity
const join_activity = (data:{GF_ID:string|number,activity_id:string}) => {
  return request({
    url: 'join_activity',
    method: 'GET',
    data: {
      visit_gfid:data.GF_ID,
      activity_data_id:data.activity_id,
      AccessKeyId:AccessKeyId,
      AccessKeySecret:AccessKeySecret,
    },
  })
}
//type:1-单位，2-赛事，3-活动
const subscribe = (data:{GF_ID:string|number,control:number,id:string,type:number}) => {
  return request({
    url: 'subscribe',
    method: 'GET',
    data: {
      visit_gfid:data.GF_ID,
      AccessKeyId:AccessKeyId,
      AccessKeySecret:AccessKeySecret,
      control:data.control,
      id:data.id,
      type:data.type,
    },
  })
}
// region_list
const region_list = (data:{code?:number}) => {
  return request({
    url: 'region_list',
    method: 'GET',
    data: {
      code:data.code || '',
    },
  })
}
//获取关注单位列表getFollowClub
const getFollowClub = (data:{AccessKeyId?:string,AccessKeySecret?:string,GF_ID?:number|string,}) => {
  return request({
    url: 'getFollowClub',
    method: 'GET',
    data: {
      AccessKeyId: data.AccessKeyId||AccessKeyId,
      AccessKeySecret: data.AccessKeySecret||AccessKeySecret,
      visit_gfid:data.GF_ID,
    },
  })
}
//downLoadComTem
const downLoadComTem = () => {
  return exportExcel({
    url: 'downLoadComTem',
    fileName:'赛事导入模板',
    type:'xlsx',
    method: 'GET',
    data: {},
  })
}
const writeScore = (data:{game_id:number|string,game_data_id:number|string,score:number|string,team_id:string}) => {
  return request({
    url: 'writeScore',
    method: 'GET',
    data: {
      game_id: data.game_id,
      game_data_id: data.game_data_id,
      score:data.score,
      team_id:data.team_id,
      //GF_ID:data.GF_ID,
    },
  })
}
const getScore = (data:{game_id:number|string,game_data_id:number|string}) => {
  return request({
    url: 'getScore',
    method: 'GET',
    data: {
      game_id: data.game_id,
      game_data_id: data.game_data_id,
    },
  })
}
const getClubList = () => {
  return request({
    url: 'getClubList',
    method: 'GET',
    data: {
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
    },
  })
}
//revoke_join_activity
const revoke_join_activity = (data:{GF_ID:string|number,activity_data_id:string|number}) => {
  return request({
    url: 'revoke_join_activity',
    method: 'GET',
    data: {
      AccessKeyId: AccessKeyId,
      AccessKeySecret: AccessKeySecret,
      visit_gfid:data.GF_ID,
      activity_data_id:data.activity_data_id,
    },
  })
}
// getSlide
const getSlide = () => {
  return request({
    url: 'getSlide',
    method: 'GET',
    data: {},
  })
}
//getGrid
const getGrid = () => {
  return request({
    url: 'getGrid',
    method: 'GET',
    data: {},
  })
}
//get_club_agreement
const get_club_agreement = () => {
  return request({
    url: 'get_club_agreement',
    method: 'GET',
    data: {},
  })
}